<?php
$T->loadTpl("./html/".$template."/".$qname.".html");
$T->SetTpl('cssjs','html/cssjs.inc'); 
$T->SetTpl('jsmodel','html/jsmodel.inc');     

$p=isset($_GET["p"])?$_GET["p"]:"1";
$t=isset($_GET["type"])?$_GET["type"]:"";
$start=isset($_GET["start"])?$_GET["start"]:"";
$end=isset($_GET["end"])?$_GET["end"]:"";
$where = "";
if(!empty($t)&&$t!='all'){$where.=" and type=".$t;$T->Set('type',$t);}
if(!empty($start)){$where.=" and start>='".$start."'";$T->Set('start',$start);}
if(!empty($end)){$where.=" and end<='".$end."'";$T->Set('end',$end);}
$offset = ($p-1)*15;
$uid=$_SESSION['uid'];
$list =$T->db->query("select * from sys_schedule where uid ='".$_SESSION['uid']."'".$where." order by time desc  limit {$offset},15")->fetchAll(PDO::FETCH_ASSOC);
$str_html = '';
foreach ($list as $k => $val) {
    $content =  strip_tags($val['content']);
    $now = date('Y-m-d H:i:s');
    if($val['start']>$now){$status='未开始';}
    elseif($val['end']<$now){$status='已过期';}
    else{$status='进行中';}
    $type = $T->db->query("select name from sys_schedule_type where id=".$val['type'])->fetchColumn(0);
    $str_html.='<tr>
                    <td>
                        <input type="checkbox" name="checkbox" lay-skin="primary" value="'.$val["id"].'"/>
                    </td>
                    <td>'.$val["id"].'</td>
                    <td>'.$val["start"].'</td>
                    <td>'.$val["end"].'</td>
                    <td>'.$type.'</td>
                    <td class="ellipsis">'.$content.'</td>
                    <td>'.$status.'</td>
                    <td>    
                        <button class="layui-btn layui-btn-mini layui-btn-normal ajax"  data-opt="view"  data-id="'.$val["id"].'">
                            <i class="iconfont">&#xe605;</i>查看
                        </button>
                        <button class="layui-btn layui-btn-mini layui-btn-danger ajax"  data-opt="del"  data-id="'.$val["id"].'">
                            <i class="iconfont">&#xe626;</i>删除
                        </button>
                    </td>
                </tr>';
}
$rc=$T->db->query("select count(*) from sys_schedule where 1=1".$where)->fetchColumn(0);
if($p<1)$p=1;
$page=getPageHtml_bt($rc,15,$p,"&t=schedule_sys_list");
$page=mb_convert_encoding($page, 'utf-8', 'utf-8');
$T->SetBlock("types","select id,name from sys_schedule_type order by odx");
$T->Set("page",$page);
$T->Set("str_html",$str_html);  

$T->Set("template",$template);         
$T->clearNaN();       
$T->clearNoN();
$T->display(); 